package demo.view;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class Welcome implements ActionListener{
	private JFrame frame = new JFrame("图书馆管理系统 ");
	 private JPanel imagePanel;
	 private ImageIcon background;

	 
	 public Welcome() {
		 

		 background = new ImageIcon(this.getClass().getResource("background.jpg"));
		 JLabel label = new JLabel(background);
		 label.setBounds(0, 0, background.getIconWidth(),background.getIconHeight());
		 imagePanel = (JPanel) frame.getContentPane(); 
		 frame.getLayeredPane().add(label, new Integer(Integer.MIN_VALUE)); 
		 
		 imagePanel.setOpaque(false);	 
		 imagePanel.setLayout(null);
		 frame.getLayeredPane().setLayout(null);
		 
		 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		 frame.setBounds(500, 200, 450, 300);
		 frame.setResizable(false);
		 frame.setVisible(true);
		 
		    JLabel title = new JLabel("图书馆管理系统");
			title.setBounds(100, 10, 300, 33);
			title.setFont(new Font("",Font.ITALIC+Font.BOLD,30));
			title.setForeground(Color.white);
			imagePanel.add(title);
			
			JButton ManagerEnterButton = new JButton("管理员入口");
			imagePanel.add(ManagerEnterButton);
			ManagerEnterButton.setBounds(124, 66, 184, 40);
			ManagerEnterButton.addActionListener(this);
			
			
			JButton ReaderEnterButton = new JButton("读者入口");
			imagePanel.add(ReaderEnterButton);
			ReaderEnterButton.setBounds(124, 148, 184, 40);
			ReaderEnterButton.addActionListener(this);
			
			
			ManagerEnterButton.addActionListener(new ActionListener()
			{
				@Override
				public void actionPerformed(ActionEvent e) 
				{
					// TODO Auto-generated method stub
					if(e.getSource()==ManagerEnterButton)
					{
						frame.dispose();
			    		new ManagerEnter();
			    		
			    	}				
				}			
			});
			
			ReaderEnterButton.addActionListener(new ActionListener()
			{
				@Override
				public void actionPerformed(ActionEvent e) 
				{
					// TODO Auto-generated method stub				
					if(e.getSource()==ReaderEnterButton)
					{
						frame.dispose();
			    		new UserEnter();
			    		
			    	}
				}			
			});
			
	 }
	 
	 public static void main(String[] args) 
	 {
		 new Welcome();	
	 	}

	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		
	}

}
